import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import fms.util.ObjectUtil;

import java.util.ArrayList;
import java.util.List;


/**
 * Created with IntelliJ IDEA.
 * To change this template use File | Settings | File Templates.
 */
public class DownRequestWindCase extends TestCase{

    private static Logger debugLogger = Logger.getLogger("forDebug");
    private static Logger errorLogger = Logger.getLogger("forError");

    public static final char EndSymbol = new Character((char) 3);
    private static final String regexGwTime = "[\\s\\S]*\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}[\\s\\S]*";
    @Override
    protected void setUp() throws Exception {
        PropertyConfigurator.configure("controller/config/log4j.properties");
        debugLogger.debug("风温接口服务已启动！");
    }

    private static Object[] RemoveEmptyLine(String[] lines)
    {
        List<String> result = new ArrayList();
        System.out.println("111==" + result.size());

        for (String item : lines)
        {
//            System.out.println("------------" + item);
            if (!ObjectUtil.isBlank(item) && !ObjectUtil.isBlank(item.trim()))
            {
//                System.out.println("++++++++" + item);
                result.add(item);
//                System.out.println(item);
            }
        }
//        System.out.println("2222==" + result.size());
        return result.toArray();
    }

    public static String[] ObjectToStringArray(Object[] objs) {
        String [] strs = new String[objs.length];
        for(int i=0;i<objs.length;i++){
            strs[i]=objs[i].toString();
        }
        return strs;
    }

    public static void testDownRequestWind() throws Exception {

//        String[] rawMsg; //=
//        rawMsg = new String[]{"2009-09-25 03:23:47\n", "\f\b\t     \r\n", "QU SHAQPHO\n"};
//                "QU SHAQPHO\n" +
//                ".BJSXCXA 260310\n" +
//                "FML\n" +
//                "FI HO1283/AN B-6311\n" +
//                "DT BJS PVG 260310 F09A\n" +
//                "- REQ PWI /CQ351 /WQ351 :ALDAP.IBEGI.ODULO.GORPI.SAGUT.IDVEL.XDX.TAO.XIVID.FD.TEKAM.IGDEG.NIXEP.TANIB.MAKNO.UDETI.VENOS.CHI.NODAL.ISKEM.BIDIB.NUBKI.LEMOT.LJB.ZYCC /DQ351 /WRZYCC.ZYTX A130 \n";
//        System.out.println(rawMsg.substring(0,rawMsg.length()-1) + rawMsg.matches(regexGwTime));

//        Object[] arr =  RemoveEmptyLine(rawMsg);
//        String[] strarr = ObjectToStringArray(arr);
////        for(String item : rawMsg) {
//            System.out.println("==" + strarr[0] + "   "+ strarr.length);
////        }
//        String rawMsg = "REQPWI/CQ351/WQ351:ALDAP.IBEGI.ODULO.GORPI.SAGUT.IDVEL.XDX.TAO.XIVID.FD.TEKAM.IGDEG.NIXEP.TANIB.MAKNO.UDETI.VENOS.CHI.NODAL.ISKEM.BIDIB.NUBKI.LEMOT.LJB.ZYCC/DQ351/WRZYCC.ZYTXA130";
//        String regexRequestWind = "REQPWI/CQ\\d+/WQ(\\d+):([\\s\\S]*?)/DQ\\d+/\\w+?\\.\\w+?\\w{4}";
//        Pattern pattern = Pattern.compile(regexRequestWind);
//        Matcher matcher = pattern.matcher(rawMsg);
//        if (matcher.matches()) {
//            String reqAlt = matcher.group(1);
//            String reqCpt = matcher.group(2);
//            reqCpt = reqCpt.replace(".", ",");
//            System.out.println(reqAlt + "   " + reqCpt);
//        }

    }
}
